#include "map.h"
void drawMap( Map map)
 {
    SDL_Rect dest,src;

    dest.x = 0;
    dest.y = 0;

    src.x = map.startX;
    src.y = map.startY;
    src.w = SCREEN_WIDTH;
    src.h = SCREEN_HEIGHT;

    SDL_BlitSurface(map.background, &src, jeu.screen, &dest);
}
void mapCollision(GameObject *entity)
{
    int x,y;

    x = entity->x + entity->dirX;

    entity->etat = 2;
    
    if(entity->x != x)
    {
        entity->etat = 1;
    }
    

    if(x+entity->w > map.maxX)
    {
        entity->x = map.maxX - entity->w - 1;
    }
    
    else if (x < 0)
    {
        entity->x = 0;
    }
    else
    {
        entity->x = x;
    }

    

    y = entity->y + entity->dirY;

    if(y > 500)
    {
        entity->y = 500;
        player.onGround = 1;
    }
    else
    {
        entity->y = y;
    }
}
